{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "77ac4db0",
   "metadata": {},
   "source": [
    "--------------------------------\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "--------------------------------"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "bcd66f0c",
   "metadata": {},
   "outputs": [],
   "source": [
    "def greet_user():\n",
    "    \"\"\"用户问候语\"\"\"\n",
    "    print(\"hello world`\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "ca0bd833",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello world`\n"
     ]
    }
   ],
   "source": [
    "greet_user()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "ab38a126",
   "metadata": {},
   "outputs": [],
   "source": [
    "def greet_user(username):\n",
    "    \"\"\"用户问候语\"\"\"\n",
    "    print(\"hello\",username)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "89bd64cd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello 李华\n"
     ]
    }
   ],
   "source": [
    "greet_user(username=\"李华\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "e78fa60f",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 函数的意义 1：重复使用\n",
    "#            2:给不了解代码的人看"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "d0c44a15",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 实践：广州南方学院新闻网站url实践函数\n",
    "def NFU_NEWS_URL(分类,页码):\n",
    "    \"\"\"广州南方学院新闻网站url数据\n",
    "       分类包含：【学校要闻:xxyw,学院动态:xydt,通知公告:tzgg,招投标:ztb】\n",
    "       页码包含:【113，106，37，27】\n",
    "    \"\"\"\n",
    "    for i in range(页码):\n",
    "        print(\"https://www.nfu.edu.cn/\"+ 分类 + \"/index\"+str(i)+\".htm\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "f052ebb1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function NFU_NEWS_URL in module __main__:\n",
      "\n",
      "NFU_NEWS_URL(分类, 页码)\n",
      "    广州南方学院新闻网站url数据\n",
      "    分类包含：【学校要闻:xxyw,学院动态:xydt,通知公告:tzgg,招投标:ztb】\n",
      "    页码包含:【113，106，37，27】\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(NFU_NEWS_URL)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "771ea326",
   "metadata": {},
   "source": [
    "## 2.模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "454569e5",
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'colloge_url_crawl'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
      "Input \u001b[1;32mIn [13]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mcolloge_url_crawl\u001b[39;00m\n",
      "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'colloge_url_crawl'"
     ]
    }
   ],
   "source": [
    "import colloge_url_crawl"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "a9aefca0",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'colloge_url_crawl' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [12]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m help(\u001b[43mcolloge_url_crawl\u001b[49m\u001b[38;5;241m.\u001b[39mNFU_NEWS_URL)\n",
      "\u001b[1;31mNameError\u001b[0m: name 'colloge_url_crawl' is not defined"
     ]
    }
   ],
   "source": [
    "help(colloge_url_crawl.NFU_NEWS_URL)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "f062f119",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'colloge_url_crawl' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [14]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mcolloge_url_crawl\u001b[49m\u001b[38;5;241m.\u001b[39mNFU_NEWS_URL(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mxydt\u001b[39m\u001b[38;5;124m\"\u001b[39m,\u001b[38;5;241m106\u001b[39m)\n",
      "\u001b[1;31mNameError\u001b[0m: name 'colloge_url_crawl' is not defined"
     ]
    }
   ],
   "source": [
    "colloge_url_crawl.NFU_NEWS_URL(\"xydt\",106)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b8e68a8f",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
